package luyao.wanandroid.util

import android.annotation.TargetApi
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.os.Build

/**
 * Created by luyao
 * on 2018/3/13 16:16
 */
class NetWorkUtils {

    companion object {
        @TargetApi(23)
        fun isNetworkAvailable(context: Context): Boolean {
            val manager = context.applicationContext.getSystemService(
                    Context.CONNECTIVITY_SERVICE) as ConnectivityManager
            val network = manager.activeNetwork
            val networkCapabilities = manager.getNetworkCapabilities(network)
            return null != networkCapabilities
        }
    }
}